<%--
  Created by IntelliJ IDEA.
  User: gaoran
  Date: 2020/7/16
  Time: 11:05
  To change this template use File | Settings | File Templates.
--%>

<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<!DOCTYPE html>
<html style="width: 100%;overflow-x: auto;position:relative ">
<head>
    <title>评测对象设置</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="/css/officialDocument/officialDocument.css">

    <link rel="stylesheet" href="/lib/layer/skin/default/layer.css">
    <link type="text/css" rel="stylesheet" href="/lib/pagination/style/pagination.css">
    <link rel="stylesheet" href="/css/base/base.css?20201106.1">

    <script src="/js/common/language.js"></script>

    <script type="text/javascript" src="/js/jquery/jquery-1.9.1.js"></script>
    <script src="/js/jquery/jquery.cookie.js"></script>
    <script type="text/javascript" src="/js/base/tablePage.js"></script>
    <script src="/lib/layer/layer.js?20201106"></script>
    <script src="/js/base/base.js"></script>
    <script src="/lib/laydate/laydate.js"></script>
    <script type="text/javascript" charset="utf-8" src="/lib/pagination/js/jquery.pagination.min.js"></script>

    <%--<script src="/js/document/makeADraft.js"></script>--%>
    <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>
    <style>

        table tr {
            border-width: 1px;
            border-style: solid;
            border-color: rgb(204, 204, 204);
            border-image: initial;
        }
        table tr th {
            font-size: 13pt;
            color: rgb(47, 92, 143);
            text-align: center;
            padding: 6px;
        }

        table  td {
            font-size: 11pt;
            padding: 6px;
            height: 30px;
            line-height: 30px;
            text-align: center;
            word-break: keep-all;
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
        }
        table tr:nth-child(2n) {
            background-color: rgb(255, 255, 255);
        }
        table tr:nth-child(2n+1) {
            background-color:#F6F7F9 ;
        }
        .newLeave {
            border-radius: 3px;
            margin-right: 3%;
            float: right;
            width: 70px;
            height: 28px;
            color: #fff;
            font-size: 14px;
            line-height: 28px;
            margin-right: 3%;
            margin-top: 14px;
            cursor: pointer;
            background: #2b7fe0
        }
        .clearfix {
            margin: 5px auto;
            width: 93%;
        }
        textarea.BigStatic {
            font-size: 10pt;
            padding: 1px 5px;
            border: 1px solid #C0BBB4;
            background: #E0E0E0;
            height: 26px;
            border-radius:5px;
            width: 125px;
            /*margin-left: 32px;*/
        }
        .index-desc{
            height: 95px;
            float: left;
            line-height: 95px;
            margin-right: 9px;
        }
        .lab-set{
            height: 50px;
            float: left;
            line-height: 47px;

        }
        #portalName{
            height: 30px;
            margin-right: 16px;
        }
        .li-set p{
            margin: 5px 0 0 103px;
        }
        .M-box3 .active {
            margin: 0px 3px;
            width: 38px;
            height: 38px;
            line-height: 38px;
            background: #2b7fe0;
            font-size: 12px;
            border: 1px solid #2b7fe0;
            color: #fff;
            text-align: center;
            display: inline-block;
        }
        .M-box3 {
            margin-top: 30px;
            position: fixed;
            bottom: 10px;
            right: 76px;
            text-align: center;
        }
        .M-box3 a {
            margin: 0 3px;
            width: 38px;
            height: 38px;
            line-height: 38px;
            font-size: 12px;
            display: inline-block;
            text-align: center;
            background: #fff;
            border: 1px solid #ebebeb;
            color: #333;
            text-decoration: none;
        }
        .jump-ipt {
            width: 38px;
            height: 38px;
            line-height: 38px;
            text-align: center;
            padding: 0;
        }
        .main{
            margin-top: 40px;
            margin-left: 44px;
            height:60px;
        }
        .main ul{
            height:40px;
            margin-top: 5px;
        }
        .main li{
            margin-right: 4%;
            float: left;
        }
        .main .leftspan{
            vertical-align: middle;
        }
        .main a{
            margin: 2px;
            color: #007cfd;
            position: relative;
            top:-12px;
        }
        #kaoheBiaoji{
            margin-left: 12px;
        }
        select {
            margin-left: 12px;
            width: 139px;
            height: 30px;
            border: 1px solid #ccc;
            border-radius: 4px;
            padding-left: 6px;
        }
        input[type=button] {
            height: 30px;
            border: 1px solid #ccc;
            border-radius: 5px;
            padding-left: 6px;
        }
        .main .orgClear{
            color: #e01919;
        }
        #newMain  .leftspan{
            display: inline-block;
            width: 156px;
            text-align: right;
            margin-right: 52px;
            vertical-align: top;
        }
        #newMain input{
            width: 250px;
            height: 30px;
            border: 1px solid #ccc;
            border-radius: 2px;
            padding-left: 6px;
        }
        #newMain li{
            list-style: none;
            margin:12px 0;
            padding: 0;
        }
        #newMain .inputsmall{
            width: 116px;
            height: 30px;
            text-align: center;
            padding-left: 0px;
        }
        #newMain select {
            width: 258px;
            height: 30px;
            border: 1px solid #ccc;
            border-radius: 2px;
            padding-left: 6px;
            margin-left: 0;
        }
        #newMain .mustinput{
            color: red;
            height: 26px;
            line-height: 32px;
            margin-left: 5px;
        }
        #newMain .btn{
            color: #2e8ded;
        }
        #newMain .clear{
            color: #e01919;
        }
        #newMain .clear3{
            color: #e01919;
        }
        #newMain .clear4{
            color: #e01919;
        }
        #newMain .adddept:hover{
            cursor:pointer;
        }
        #newMain .clear:hover{
            cursor:pointer;
        }
        .head-top {
            width: 100%;
            position: fixed;
            top: 0px;
            left: 0px;
            height: 45px;
            border-bottom: 1px solid #999;
            background: #fff;
            overflow: hidden;
            z-index: 9999999;
        }
        .head-top ul .head-top-li {
            height: 26px;
            line-height: 26px;
            margin: 6px 11px 0px 11px;
            padding: 1px 20px;
            font-size: 14px;
            border-radius: 20px;
            cursor: pointer;
        }
        .navigation {
            width: 100%;
            box-sizing: border-box;
            height: 70px;
            padding-left: 34px;
            line-height: 70px;
        }
        .navigation img {
            vertical-align: middle;
        }
        .navigation h2 {
            font-weight: normal;
            display: inline-block;
            font-size: 22px;
            color: #494d59;
            vertical-align: middle;
            margin-left: 10px;
        }
        .two table th,.two table tr,.two table tr td{
            border:1px solid grey;
        }
        .morebutton{
            width: 38px;
            height: 22px;
            border-radius: 3px;
            border: 1px solid gray;
            background-color: #ffffff;
        }
        .savebtn{
            margin-right: 10px;
        }
        .savebtn,.back{
            border-color: #4898d5;
            background-color: #2e8ded;
            color: #fff;
            padding: 5px 15px;
        }
        .piliang button{
            margin-right: 10px;
            border: 1px slategrey solid;
        }
        input[type=number]{
            background: none;
        }
        input::-webkit-outer-spin-button,
        input::-webkit-inner-spin-button {
            -webkit-appearance: none;
        }
        input[type="number"]{
            -moz-appearance: textfield;
        }
        input[type=text]{
            background: none;
            border: none;
        }
    </style>
</head>
<body>
<div class="navigation">
    <img src="/img/kaoheguanli.png" alt="">
    <h2>评测方案管理-评测对象设置</h2>
    <h3 style="margin-top: -32px;font-size: 14px;">设置评测对象的参评人员</h3>
    <h3 class="user_msg_h3" style="margin-top: -46px;font-size: 14px;">评测对象：</h3>
</div>
<table class="user_table" style="margin:42px auto;width:95%;" >
    <thead>
    <tr style="background: none">
        <th style="width:12%">姓名</th>
        <th style="width:12%">部门</th>
        <th style="width:12%">职位 </th>
    </tr>
    </thead>
    <tbody id="taskBody">
    </tbody>
</table>
<div class="piliang" style="margin-top: 35px; padding-left: 34px;">
    <input type="button"  onclick="psemFn($(this))" style="width: 100px" value="批量设置上级" privType="1"/>
    <input type="button"  onclick="psemFn($(this))" style="width: 100px" value="批量设置平级" privType="2"/>
    <input type="button"  onclick="psemFn($(this))" style="width: 100px" value="批量设置下级" privType="3"/>
</div>
<div class="two" style="margin-top: 65px">
    <h3 style="margin-top: -36px;margin-left: 33px;font-size: 14px;">评测对象的参评人员列表：</h3>
    <table style="margin:0 auto;width:95%;">
        <thead>
        <tr>
            <th>角色</th>
            <th>权重</th>
            <th>姓名</th>
            <th>考核角色</th>
            <th>人员权重</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody id="taskBody1">
        </tbody>
        <%--<tr>--%>
        <%--<td>上级</td>--%>
        <%--<td>平级</td>--%>
        <%--<td>下级</td>--%>
        <%--<td>$100</td>--%>
        <%--</tr>--%>
    </table>

</div>

<div id="dbgz_page" class="M-box3" style="display: none">
</div>
<script>
    function getQueryString(name){
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  unescape(r[2]); return null;
    }
    var userId =getQueryString("userId");
    var flowId = getQueryString("flowId");
    var flowFlag = getQueryString("flowFlag");
    var insertType = getQueryString("insertType");
    var queryType = getQueryString("queryType");
    var userIds = getQueryString("userIds");

    //列表带分页
    function undefindData(data) {
        if(data == undefined){
            return '';
        }else{
            return data;
        }
    }
    var ajaxPageTr={
        data:{
            userId:userId
        },
        page:function () {
            var me=this;
            layer.msg('加载中', {
                icon: 16
                ,shade: 0.01
            });
            $.ajax({
                type:'get',
                url:'/user/findUserByuserId',
                dataType:'json',
                data:me.data,
                success:function(res){
                    if(res){
                        var str='';
                        $.each(res.object, function (index, item) {
                            str = '<tr userId="'+item.userId+'">' +
                                '<td title="'+undefindData(res.object.userName) +'">' + undefindData(res.object.userName) + '</td>' +
                                '<td title="'+undefindData(res.object.deptName)+'">' + undefindData(res.object.deptName)+ '</td>' +
                                '<td title="'+undefindData(res.object.userPrivName)+'">' + undefindData(res.object.userPrivName)+ '</td>' +
                                '</tr>';

                        })
                        $('#taskBody').html(str)
                        layer.closeAll();
                        me.pageTwo(res.totle,me.data.pageSize,me.data.page)
                    }else{
                        layer.msg("暂无数据", {icon: 2})
                    }

                }
            })

            if(queryType!=undefined&queryType>0){
                $.ajax({
                    type:'get',
                    url:'/scoreFlowUser/selAssessors',
                    dataType:'json',
                    data:{
                        scoreFlowId:flowId,
                        userId:userId
                    },
                    success:function(res){
                        if(res){
                            var str='';
                            var privUsers1 = res.data.privUsers1;
                            var privUsers2 = res.data.privUsers2;
                            var privUsers3 = res.data.privUsers3;
                            if(privUsers1.length>0){
                                // 遍历上级
                                for(var i=0,length=privUsers1.length;i<length;i++){
                                    var privUser = privUsers1[i];
                                    var dynamic=i+1;
                                    if(i==0){
                                        str+='<tr id="one" class="top"><td  rowspan="'+length+'">上级</td>' +
                                            '<td rowspan="'+length+'" ><input type="number" oninput="weightNum($(this))" value="'+privUser.privWeight+'" /></td>' +
                                            '<td><input autocomplete="off" type="text" style="border: none;background: none;width: 100%;height: 100%;text-align: center" name="postPriv" class="user_select_input" onclick="semFn($(this))" id="userId'+dynamic +'" user_id="'+privUser.assessor+'," value="'+privUser.assessorName+'"/></td>' +
                                            '<td><input type="text" name="assessmentRole" value="'+(privUser.assessmentRole || '')+'" /></td>' +
                                            '<td class="sj" ><input type="number" oninput="weightNum($(this))" value="'+privUser.assessorWeight+'" /></td>' +
                                            '<td><button class="morebutton" id="btn1"  num="'+length+'"onclick="addpeople()">添加</button>' +
                                            '<button class="morebutton" id="btnde" onclick="delTable($(this))" style="margin-left:6px;display: none">删除</button>' +
                                            '</td></tr>' ;
                                    } else {
                                        str+='<tr class="top"><td  style="display:none">上级</td>' +
                                            '<td style="display:none"><input type="number" oninput="weightNum($(this))" value="'+privUser.privWeight+'" /></td>' +
                                            '<td><input type="text" autocomplete="off" style="border: none;background: none;width: 100%;height: 100%;text-align: center" name="postPriv" class="user_select_input" onclick="semFn($(this))" id="userId'+dynamic +'" user_id="'+privUser.assessor+'," value="'+privUser.assessorName+'"/></td>' +
                                            '<td><input type="text"  name="assessmentRole"  value="'+(privUser.assessmentRole || '')+'" /></td>' +
                                            '<td class="sj" ><input type="number" oninput="weightNum($(this))" value="'+privUser.assessorWeight+'" /></td>'+
                                            '<td><button class="morebutton" id="btnde" onclick="delTable($(this))" style="margin-left:6px">删除</button></td>';
                                    }
                                }
                            }else{
                                str+='<tr id="one" class="top"><td>上级</td><td ><input type="number" oninput="weightNum($(this))" /></td><td><input autocomplete="off" type="text" style="border: none;background: none;width: 100%;height: 100%;text-align: center" name="postPriv"class="user_select_input" onclick="semFn($(this))" id="userId1"/></td><td><input type="text"  name="assessmentRole"  /></td><td class="sj"><input type="number" /></td>' +
                                    '<td><button class="morebutton bg" id="btn1"  num="1"onclick="addpeople()">添加</button>' +
                                    '<button class="morebutton" id="btnde" onclick="delTable($(this))" style="margin-left:6px;display: none">删除</button></td></tr>'
                            }
                            if(privUsers2.length>0){
                                // 遍历平级
                                for(var i=0,length=privUsers2.length;i<length;i++){
                                    var privUser = privUsers2[i];
                                    var dynamic2=i+1;
                                    if(i==0){
                                        str+='<tr id="one2" class="top2"><td  rowspan="'+length+'">平级</td>' +
                                            '<td rowspan="'+length+'" ><input type="number" oninput="weightNum($(this))" value="'+privUser.privWeight+'" /></td>' +
                                            '<td><input autocomplete="off" type="text" style="border: none;background: none;width: 100%;height: 100%;text-align: center" name="postPriv2" class="user_select_input" onclick="semFn2($(this))"  id="tuserId'+dynamic2 +'" user_id="'+privUser.assessor+'," value="'+privUser.assessorName+'"/></td>' +
                                            '<td><input type="text"  name="assessmentRole"  value="'+(privUser.assessmentRole || '')+'" /></td>' +
                                            '<td class="sj2" ><input type="number" oninput="weightNum($(this))" value="'+privUser.assessorWeight+'" /></td>' +
                                            '<td><button class="morebutton" id="btn2"  num="'+length+'"onclick="addpeople2()">添加</button>' +
                                            '<button class="morebutton" id="btnde2" onclick="delTable2($(this))" style="margin-left:6px;display: none">删除</button></td></tr>' ;
                                    } else {
                                        str+='<tr class="top2"><td  style="display:none">平级</td>' +
                                            '<td style="display:none">><input type="number" oninput="weightNum($(this))" value="'+privUser.privWeight+'" /></td>' +
                                            '<td><input autocomplete="off" type="text" style="border: none;background: none;width: 100%;height: 100%;text-align: center" name="postPriv2" class="user_select_input" onclick="semFn2($(this))" id="tuserId'+dynamic2 +'" user_id="'+privUser.assessor+'," value="'+privUser.assessorName+'"/></td>' +
                                            '<td><input type="text"  name="assessmentRole"  value="'+(privUser.assessmentRole || '')+'" /></td>' +
                                            '<td class="sj2" ><input type="number" oninput="weightNum($(this))" value="'+privUser.assessorWeight+'" /></td>'+
                                            '<td><button class="morebutton" id="btnde2" onclick="delTable2($(this))" style="margin-left:6px">删除</button></td>';
                                    }
                                }
                            }else{
                                str+= '<tr id="one2" class="top2"><td>平级</td><td ><input type="number" oninput="weightNum($(this))" value="" /></td>' +
                                    '<td><input autocomplete="off" type="text"  style="border: none;background: none;width: 100%;height: 100%;text-align: center" name="postPriv2" class="user_select_input" onclick="semFn2($(this))" id="tuserId1" /></td>' +
                                    '<td><input type="text"  name="assessmentRole"  /></td>' +
                                    '<td class="sj2" ><input type="number" oninput="weightNum($(this))" value="" /></td>' +
                                    '<td><button class="morebutton" id="btn2"  num="1"onclick="addpeople2()">添加</button>' +
                                    '<button class="morebutton"id="btnde2"  onclick="delTable2($(this))" style="margin-left:6px;display: none">删除</button></td></tr>' +
                                    '</tr>'
                            }
                            if(privUsers3.length>0){
                                // 遍历下级
                                for(var i=0,length=privUsers3.length;i<length;i++){
                                    var privUser = privUsers3[i];
                                    var dynamic3=i+1;
                                    if(i==0){
                                        str+='<tr id="one3" class="top3"><td  rowspan="'+length+'">下级</td>' +
                                            '<td rowspan="'+length+'" ><input type="number" oninput="weightNum($(this))" value="'+privUser.privWeight+'" /></td>' +
                                            '<td><input type="text" autocomplete="off" style="border: none;background: none;width: 100%;height: 100%;text-align: center" name="postPriv3" class="user_select_input" onclick="semFn3($(this))" id="euserId'+dynamic3 +'" user_id="'+privUser.assessor+'," value="'+privUser.assessorName+'"/></td>' +
                                            '<td><input type="text"  name="assessmentRole"  value="'+(privUser.assessmentRole || '')+'" /></td>' +
                                            '<td class="sj3" ><input type="number" oninput="weightNum($(this))" value="'+privUser.assessorWeight+'" /></td>' +
                                            '<td><button class="morebutton" id="btn3"  num="'+length+'"onclick="addpeople3()">添加</button>' +
                                            '<button class="morebutton" id="btnde3" onclick="delTable3($(this))" style="margin-left:6px;display: none">删除</button></td></tr>' ;
                                    } else {
                                        str+='<tr class="top3"><td  style="display:none">下级</td>' +
                                            '<td style="display:none"><input type="number" oninput="weightNum($(this))" value="'+privUser.privWeight+'" /></td>' +
                                            '<td><input autocomplete="off" type="text" style="border: none;background: none;width: 100%;height: 100%;text-align: center" name="postPriv3" class="user_select_input" onclick="semFn3($(this))" id="euserId'+dynamic3+'" user_id="'+privUser.assessor+'," value="'+privUser.assessorName+'"/></td>' +
                                            '<td><input type="text"  name="assessmentRole"  value="'+(privUser.assessmentRole || '')+'" /></td>' +
                                            '<td class="sj3" ><input type="number" oninput="weightNum($(this))" value="'+privUser.assessorWeight+'" /></td>'+
                                            '<td><button class="morebutton" id="btnde3" onclick="delTable3($(this))" style="margin-left:6px">删除</button></td>';
                                    }
                                }
                            }else{
                                str+= '<tr id="one3" class="top3"><td>下级</td><td ><input type="number" oninput="weightNum($(this))" value="" /></td>' +
                                    '<td><input autocomplete="off" type="text"  style="border: none;background: none;width: 100%;height: 100%;text-align: center" name="postPriv3" class="user_select_input" onclick="semFn3($(this))" id="euserId1" /></td>' +
                                    '<td><input type="text"  name="assessmentRole"   /></td>' +
                                    '<td class="sj3"><input type="number" oninput="weightNum($(this))" value="" /></td><td>' +
                                    '<button class="morebutton" id="btn3"  num="1"onclick="addpeople3()">添加</button>' +
                                    '<button class="morebutton"  id="btnde3" onclick="delTable3($(this))" style="margin-left:6px;display: none">删除</button>'+
                                    '</td></tr>'
                            }
                            str+='<tr>'+
                                '<td colspan="6" style="text-align: center" class="">'+
                                '<a href="javascript:;" class="savebtn">保存</a><a href="javascript:;" class="back">返回</a>'+
                                '</td></tr>';

                            $('#taskBody1').html(str);
                            layer.closeAll();
                        }else{
                            layer.msg("暂无数据", {icon: 2})
                        }

                    }
                })
            } else {
                var str2='';
                str2='<tr id="one" class="top"><td>上级</td><td ><input type="number" oninput="weightNum($(this))" value="" /></td><td><input autocomplete="off" type="text" style="border: none;background: none;width: 100%;height: 100%;text-align: center" name="postPriv" class="user_select_input" onclick="semFn($(this))" id="userId1"/></td><td><input type="text"  name="assessmentRole"   /></td><td class="sj"><input type="number" value="" /></td>' +
                    '<td><button class="morebutton bg" id="btn1"  num="1"onclick="addpeople()">添加</button>' +
                    '<button class="morebutton" id="btnde" onclick="delTable($(this))" style="margin-left:6px;display: none">删除</button></td></tr>' +
                    '<tr id="one2" class="top2"><td>平级</td><td ><input type="number" oninput="weightNum($(this))" value="" /></td><td><input autocomplete="off" type="text"  style="border: none;background: none;width: 100%;height: 100%;text-align: center" name="postPriv2" class="user_select_input" onclick="semFn2($(this))" id="tuserId1"/></td><td><input type="text"  name="assessmentRole"   /></td><td class="sj2" ><input type="number" value="" /></td>' +
                    '<td><button class="morebutton" id="btn2"  num="1"onclick="addpeople2()">添加</button>' +
                    '<button class="morebutton"id="btnde2"  onclick="delTable2($(this))" style="margin-left:6px;display: none">删除</button></td></tr>' +
                    '</tr>' +
                    '<tr id="one3" class="top3"><td>下级</td><td ><input type="number" oninput="weightNum($(this))" value="" /></td><td><input autocomplete="off" type="text"  style="border: none;background: none;width: 100%;height: 100%;text-align: center" name="postPriv3" class="user_select_input" onclick="semFn3($(this))" id="euserId1"/></td><td><input type="text"  name="assessmentRole"   /></td><td class="sj3"><input type="number" value="" /></td><td>' +
                    '<button class="morebutton" id="btn3"  num="1"onclick="addpeople3()">添加</button>' +
                    '<button class="morebutton"  id="btnde3" onclick="delTable3($(this))" style="margin-left:6px;display: none">删除</button>'+
                    '</td></tr>'+
                    '<tr>'+
                    '<td colspan="6" style="text-align: center" class="">'+
                    '<a href="javascript:;" class="savebtn">保存</a><a href="javascript:;" class="back">返回</a>'+
                    '</td></tr>'
                $('#taskBody1').html(str2)
            }
        },
        pageTwo:function (totalData, pageSize,indexs) {
            var mes=this;
            $('#dbgz_page').pagination({
                totalData: totalData,
                showData: pageSize,
                prevContent:'上一页',
                nextContent:'下一页',
                jump: true,
                coping: true,
                homePage:'',
                endPage: '',
                current:indexs||1,
                callback: function (index) {
                    mes.data.page=index.getCurrent();
                    mes.page();
                }
            });
        }
    }
    if(insertType!='1'){
        ajaxPageTr.page();
    }else {
        $('.user_table').hide();
        $('.user_msg_h3').hide();
        var str2='';
        str2='<tr id="one" onclick="selectUserCb($(this))" class="top" style="border:1px solid red!important"><td>上级</td><td ><input type="number" oninput="weightNum($(this))" value="" /></td><td><input autocomplete="off" type="text" style="border: none;background: none;width: 100%;height: 100%;text-align: center" name="postPriv" class="user_select_input" onclick="semFn($(this))" id="userId1"/></td><td><input type="text"  name="assessmentRole"   /></td><td class="sj" ><input type="number" value="" /></td>' +
            '<td><button class="morebutton" id="btn1"  num="1"onclick="addpeople()">添加</button>' +
            '<button class="morebutton" id="btnde" onclick="delTable($(this))" style="margin-left:6px;display: none">删除</button></td></tr>' +
            '<tr id="one2"  onclick="selectUserCb($(this))"class="top2"><td>平级</td><td ><input type="number" oninput="weightNum($(this))" value="" /></td><td><input autocomplete="off" type="text"  style="border: none;background: none;width: 100%;height: 100%;text-align: center" name="postPriv2" class="user_select_input" onclick="semFn2($(this))" id="tuserId1"/></td><td><input type="text"  name="assessmentRole"   /></td><td class="sj2" ><input type="number" value="" /></td>' +
            '<td><button class="morebutton" id="btn2"  num="1"onclick="addpeople2()">添加</button>' +
            '<button class="morebutton"id="btnde2"  onclick="delTable2($(this))" style="margin-left:6px;display: none">删除</button></td></tr>' +
            '</tr>' +
            '<tr id="one3" onclick="selectUserCb($(this))" class="top3"><td>下级</td><td ><input type="number" oninput="weightNum($(this))" value="" /></td><td><input autocomplete="off" type="text"  style="border: none;background: none;width: 100%;height: 100%;text-align: center" name="postPriv3" class="user_select_input" onclick="semFn3($(this))" id="euserId1"/></td><td><input type="text"  name="assessmentRole"   /></td><td class="sj3"><input type="number" value="" /></td><td>' +
            '<button class="morebutton" id="btn3"  num="1"onclick="addpeople3()">添加</button>' +
            '<button class="morebutton"  id="btnde3" onclick="delTable3($(this))" style="margin-left:6px;display: none">删除</button>'+
            '</td></tr>'+
            '<tr>'+
            '<td colspan="6" style="text-align: center" class="">'+
            '<a href="javascript:;" class="savebtn">保存</a><a href="javascript:;" class="back">返回</a>'+
            '</td></tr>'
        $('#taskBody1').html(str2);
    }
    var num=$("#userId")+1;
    var gro;
    var gro2;
    var gro3;
    function addpeople(userId,userName){
        userId = userId==undefined?'':userId;
        userName = userName==undefined?'':userName;
        var tableN = $("#taskBody1").find('input[name="postPriv"]');
        var num = $(tableN).eq(tableN.length-1).attr("id");
        var nb = tableN.length+1; //Number(num.substr(num.length-1,1))+1;
        gro = "#userId"+nb;
        $(".top").eq($(".top").length-1).after('<tr class="top"><td style="display: none">上级</td><td style="display: none"></td><td><input autocomplete="off" type="text"  style="border: none;background: none;width: 100%;height: 100%;text-align: center" name="postPriv" class="user_select_input" user_id="'+userId+'" onclick="semFn($(this))" id="userId'+nb +'" value="'+userName+'" /></td><td><input type="text"  name="assessmentRole"   /></td><td class="sj" ><input type="number" oninput="weightNum($(this))" /></td><td><button class="morebutton" id="btnde" onclick="delTable($(this))" style="margin-left:6px ">删除</button></td></tr>');
        var n = $("#btn1").attr("num");
        var nn = Number(n)+1;
        $("#btn1").attr("num",nn);
        $("#btn1").parents("tr#one").find("td").eq(0).attr("rowspan",nn);
        $("#btn1").parents("tr#one").find("td").eq(1).attr("rowspan",nn);
    }
    function addpeople2(userId,userName){
        userId = userId==undefined?'':userId;
        userName = userName==undefined?'':userName;
        var tableN = $("#taskBody1").find('input[name="postPriv2"]');
        var num = $(tableN).eq(tableN.length-1).attr("id");
        var nb =  tableN.length+1;//Number(num.substr(num.length-1,1))+1;
        gro2 = "#tuserId"+nb;
        $(".top2").eq($(".top2").length-1).after('<tr class="top2"><td style="display: none">平级</td><td style="display: none"></td><td><input autocomplete="off" type="text" style="border: none;background: none;width: 100%;height: 100%;text-align: center"  name="postPriv2" class="user_select_input" user_id="'+userId+'" onclick="semFn2($(this))" id="tuserId'+nb +'" value="'+userName+'" /></td><td><input type="text"  name="assessmentRole"   /></td><td class="sj2" ><input type="number" oninput="weightNum($(this))" /></td><td><button class="morebutton" id="btnde2" onclick="delTable2($(this))" style="margin-left:6px ">删除</button></td></tr>');
        var n = $("#btn2").attr("num");
        var nn = Number(n)+1;
        $("#btn2").attr("num",nn);
        $("#btn2").parents("tr#one2").find("td").eq(0).attr("rowspan",nn);
        $("#btn2").parents("tr#one2").find("td").eq(1).attr("rowspan",nn);

    }
    function addpeople3(userId,userName){
        userId = userId==undefined?'':userId;
        userName = userName==undefined?'':userName;
        var tableN = $("#taskBody1").find('input[name="postPriv3"]');
        var num = $(tableN).eq(tableN.length-1).attr("id");
        var nb = tableN.length+1;// Number(num.substr(num.length-1,1))+1;
        // var cn = ".sj3"
        gro3 = "#euserId"+nb;
        $(".top3").eq($(".top3").length-1).after('<tr class="top3"><td style="display: none">下级</td><td style="display: none"></td><td><input autocomplete="off" type="text"  style="border: none;background: none;width: 100%;height: 100%;text-align: center" name="postPriv3" class="user_select_input" user_id="'+userId+'" id="euserId'+nb +'" onclick="semFn3($(this))" value="'+userName+'" /></td><td><input type="text"  name="assessmentRole"   /></td><td class="sj3"><input type="number" oninput="weightNum($(this))" /></td><td><button class="morebutton" id="btnde3" onclick="delTable3($(this))" style="margin-left:6px ">删除</button></td></tr>');
        var n = $("#btn3").attr("num");
        var nn = Number(n)+1;
        $("#btn3").attr("num",nn);
        $("#btn3").parents("tr#one3").find("td").eq(0).attr("rowspan",nn);
        $("#btn3").parents("tr#one3").find("td").eq(1).attr("rowspan",nn);

    }
    function delTable(elem){
        $(elem).parents("tr").remove();
        var trs = $("#taskBody1").find('#btn1').parents("tr.top").find("td").eq(0).attr("rowspan");
        var $tbod = $("#taskBody1").find(".sj");
        var abc=$("#taskBody1").find(".sj").length;
        for(var i=0;i<$tbod.length;i++){
            $($tbod).eq(i).find('input').val(Number(keepTwoDecimalFull(1/abc, 4)))
        }
        var tableN = $("#taskBody1").find('input[name="postPriv"]');
        var num = $(tableN).eq(tableN.length-1).attr("id");
        var n = $("#btn1").attr("num");
        if(trs>1) {
            var nn = Number(n)-1;
            $("#btn1").attr("num",nn);
            $("#btnde").parents("tr#one").find("td").eq(0).attr("rowspan",trs-1);
            $("#btnde").parents("tr#one").find("td").eq(1).attr("rowspan",trs-1);
            $(trs[trs-1]).remove()
        }else{
            $("#btn1").attr("num",1);
            $("#btnde").parents("tr#one").find("td").eq(0).attr("rowspan",1);
            $("#btnde").parents("tr#one").find("td").eq(1).attr("rowspan",1);
        }
    }
    function delTable2(elem){
        $(elem).parents("tr").remove();
        var trs = $("#taskBody1").find('#btn2').parents("tr.top2").find("td").eq(0).attr("rowspan");
        var $tbod2 = $("#taskBody1").find(".sj2");
        var abc2=$("#taskBody1").find(".sj2").length;
        for(var i=0;i<$tbod2.length;i++){
            $($tbod2).eq(i).find('input').val(Number(keepTwoDecimalFull(1/abc2, 4)))
        }
        var tableN = $("#taskBody1").find('input[name="postPriv2"]');
        var num = $(tableN).eq(tableN.length-1).attr("id");
        var n = $("#btn2").attr("num");
        if(trs>1){
            var nn = Number(n)-1;
            $("#btn2").attr("num",nn);
            $("#btnde2").parents("tr#one2").find("td").eq(0).attr("rowspan",trs-1);
            $("#btnde2").parents("tr#one2").find("td").eq(1).attr("rowspan",trs-1);
            $(trs[trs-1]).remove()
        }else{
            $("#btn2").attr("num",1);
            $("#btnde2").parents("tr#one2").find("td").eq(0).attr("rowspan",1);
            $("#btnde2").parents("tr#one2").find("td").eq(1).attr("rowspan",1);
        }
    }
    function delTable3(elem){
        $(elem).parents("tr").remove();
        var trs = $("#taskBody1").find('#btn3').parents("tr.top3").find("td").eq(0).attr("rowspan");
        var $tbod3 = $("#taskBody1").find(".sj3");
        var abc3=$("#taskBody1").find(".sj3").length;
        for(var i=0;i<$tbod3.length;i++){
            $($tbod3).eq(i).find('input').val(Number(keepTwoDecimalFull(1/abc3, 4)))
        }
        var tableN = $("#taskBody1").find('input[name="postPriv3"]');
        var num = $(tableN).eq(tableN.length-1).attr("id");
        var n = $("#btn3").attr("num");
        if(trs>1){
            var nn = Number(n)-1;
            $("#btn3").attr("num",nn);
            $("#btnde3").parents("tr#one3").find("td").eq(0).attr("rowspan",trs-1);
            $("#btnde3").parents("tr#one3").find("td").eq(1).attr("rowspan",trs-1);
        }else{
            $("#btn3").attr("num",1);
            $("#btnde3").parents("tr#one3").find("td").eq(0).attr("rowspan",1);
            $("#btnde3").parents("tr#one3").find("td").eq(1).attr("rowspan",1);
        }
    }

    // 批量设置上级
    function selectUserData(res){
        console.log(selPrivTpe);
        var totaln=res.userId.split(",")
        var totalna=res.username.split(",")
        for(var z=0;z<totaln.length;z++){
            if(selPrivTpe=='1'){// 设置上级
                if(totaln[z]!=''){
                    if($('#userId1').val()==''){
                        $('#userId1').val(totalna[z]);
                        $('#userId1').attr('user_id',totaln[z]+',');
                    } else {
                        addpeople(totaln[z]+',',totalna[z]);
                    }
                }
            } else if(selPrivTpe=='2'){ // 设置平级
                if(totaln[z]!=''){
                    if($('#tuserId1').val()==''){
                        $('#tuserId1').val(totalna[z]);
                        $('#tuserId1').attr('user_id',totaln[z]+',');
                    } else {
                        addpeople2(totaln[z]+',',totalna[z]);
                    }
                }
            } else if(selPrivTpe=='3'){ // 设置下级
                if(totaln[z]!=''){
                    if($('#euserId1').val()==''){
                        $('#euserId1').val(totalna[z]);
                        $('#euserId1').attr('user_id',totaln[z]+',');
                    } else {
                        addpeople3(totaln[z]+',',totalna[z]);
                    }
                }
            }
        }

        if(selPrivTpe=='1'){// 上级计算平均权重
            var $tbod = $("#taskBody1").find(".sj");
            var abc=$("#taskBody1").find(".sj").length;
            for(var i=0;i<$tbod.length;i++){
                $($tbod).eq(i).find('input').val(Number(keepTwoDecimalFull(1/abc, 4)))
            }
        } else if(selPrivTpe=='2'){ // 平级计算平均权重
            var $tbod2 = $("#taskBody1").find(".sj2");
            var abc2=$("#taskBody1").find(".sj2").length;
            for(var j=0;j<$tbod2.length;j++){
                $($tbod2).eq(j).find('input').val(Number(keepTwoDecimalFull(1/abc2, 4)))
            }
        } else if(selPrivTpe=='3'){ // 下级计算平均权重
            var $tbod3 = $("#taskBody1").find(".sj3");
            var abc3=$("#taskBody1").find(".sj3").length;
            for(var z=0;z<$tbod3.length;z++){
                $($tbod3).eq(z).find('input').val(Number(keepTwoDecimalFull(1/abc3, 4)))
            }
        }

    }
    function psemFn(res) {
        selPrivTpe = res.attr("privType");
        $.popWindow("/scoreFlowUser/selectUser");
    }
    function semFn(res) {
        selPrivTpe = '0'
        var aoo="";
        var Uid = $(res).attr("id");
        user_id = Uid;
        $.popWindow("/scoreFlowUser/selectUser?0");
        var $tbod = $("#taskBody1").find(".sj");
        var abc=$("#taskBody1").find(".sj").length;
        for(var i=0;i<$tbod.length;i++){
            $($tbod).eq(i).find('input').val(Number(keepTwoDecimalFull(1/abc, 4)))
        }
    }
    function semFn2(res) {
        selPrivTpe = '0'
        var Uid = $(res).attr("id");
        user_id = Uid;
        $.popWindow("/scoreFlowUser/selectUser?0");
        var $tbod2 = $("#taskBody1").find(".sj2");
        var abc2=$("#taskBody1").find(".sj2").length;
        for(var j=0;j<$tbod2.length;j++){
            $($tbod2).eq(j).find('input').val(Number(keepTwoDecimalFull(1/abc2, 4)))
        }
    }
    function semFn3(res) {
        selPrivTpe = '0'
        var Uid = $(res).attr("id");
        user_id = Uid;
        $.popWindow("/scoreFlowUser/selectUser?0");
        var $tbod3 = $("#taskBody1").find(".sj3");
        var abc3=$("#taskBody1").find(".sj3").length;
        for(var z=0;z<$tbod3.length;z++){
            $($tbod3).eq(z).find('input').val(Number(keepTwoDecimalFull(1/abc3, 4)))
        }
    }
    //点击保存
    $(document).on('click', '.savebtn', function () {
        // 人员左侧等级拼接
        var base=$("#taskBody1").find("tr#one td").eq(0).html();
        var base1=$("#taskBody1").find("tr#one2 td").eq(0).html();
        var base2=$("#taskBody1").find("tr#one3 td").eq(0).html();
        if(base=="上级"){
            base=1;
        }
        if(base1=="平级"){
            base1=2;
        }
        if(base2=="下级"){
            base2=3;
        }
        var baseinfo=$("#taskBody1").find("tr#one td").eq(1).find('input').val();
        var baseinfo2=$("#taskBody1").find("tr#one2 td").eq(1).find('input').val();
        var baseinfo3=$("#taskBody1").find("tr#one3 td").eq(1).find('input').val();
        var privWeightStr='';
        // +1不要删掉 具体可以百度查询 0.1+0.2 和 0.7+0.1的问题
        if((Number(baseinfo)+1)+(Number(baseinfo2)+1)+(Number(baseinfo3)+1)-3!=1){
            layer.msg("角色的权重加起来要等于1，请重新输入", {icon: 2,time: 1500})
            return false;
        }else{
            var alist=[];
            if(baseinfo!==""){
                alist.push(base+'|'+baseinfo)
            }else{
                alist.push("")
            }
            if(baseinfo2!==""){
                alist.push(base1+'|'+baseinfo2)
            }else{
                alist.push("")
            }
            if(baseinfo3!==""){
                alist.push(base2+'|'+baseinfo3)
            }else{
                alist.push("")
            }

        }
        for(var z=0;z<alist.length;z++){
            if(alist[z]==""){
            }else{
                privWeightStr+= alist[z]+","
            }
        }
        //每个人员右侧级别拼接
        var arr = [];
        /*【考核角色】拼接*/
        var assessmentRoleArr=[]
        var assessmentRole="";

        var tyuu="";
        var $tbod = $("#taskBody1").find("tr");
        // 上级
        var $lone = $("#taskBody1").find("tr.top");
        var userWeightCount = 0;
        for(var i=0;i<$lone.length;i++){
            var qz1 = $("#taskBody1").find("tr.top").eq(0).find("td").eq(1).find('input').val();
            var $trb1 = $($lone).eq(i).find("td");
            var str1 = "";
            var assessmentRoleStr = "";
            if(qz1==""||qz1=="0"){
                if($($lone).eq(i).find("td").eq(2).find("input").attr("user_id")!=undefined&&$($lone).eq(i).find("td").eq(2).find("input").attr("user_id")!=''){
                    layer.msg("保存失败，未填写上级权重，请填写权重或者删除人员", {
                        icon: 2,
                        time: 3000 //2秒关闭（如果不配置，默认是3秒）
                    })
                    return;
                }
                str1 = "";
                $($lone).eq(i).find("td").eq(2).find("input").attr("user_id","");
                $($lone).eq(i).find("td").eq(2).find("input").attr("username","");
                $($lone).eq(i).find("td").eq(2).find("input").attr("dataid","");
                $($lone).eq(i).find("td").eq(2).find("input").attr("userprivname","");
                $($lone).eq(i).find("td").eq(2).find("input").val("");
                $($lone).eq(i).find("td").eq(4).text("");
            }else{
                var userId1 = $($lone).eq(i).find("td").eq(2).find("input").attr("user_id");
                var userWeight1 = $($lone).eq(i).find("td").eq(4).find('input').val();
                var assessmentRoleItem = $($lone).eq(i).find("td").eq(3).find('input').val();
                if(i==0&&(userId1==undefined||userId1=='')){
                    layer.msg("保存失败，未选择上级人员，请选择人员或者删除权重", {
                        icon: 2,
                        time: 3000 //2秒关闭（如果不配置，默认是3秒）
                    })
                    return;
                }
                if(userId1!=undefined&&userId1!=''){
                    str1 = cha($($lone).eq(i).find("td").eq(0).text())+"*"+cha1(userId1) + "|" + userWeight1;
                    assessmentRoleStr = cha($($lone).eq(i).find("td").eq(0).text())+"*"+assessmentRoleItem
                    userWeightCount+=Number(keepTwoDecimalFull(userWeight1, 4));
                    assessmentRoleArr.push(assessmentRoleStr);
                }
            }
            arr.push(str1);
            
        }
        // 判断上级人员总权重是否在0.99-1.01范围内
        if(userWeightCount > 0 && (keepTwoDecimalFull(userWeightCount) < 0.99 || keepTwoDecimalFull(userWeightCount) > 1.01)){
            layer.msg("保存失败，上级人员总权重不为1", {
                icon: 2,
                time: 3000 //2秒关闭（如果不配置，默认是3秒）
            })
            return;
        } else{
            userWeightCount = 0;
        }
        // if(Math.round(userWeightCount)>1||Math.round(userWeightCount)<0){
        //     layer.msg("保存失败，上级人员权重不在0-1范围内", {
        //         icon: 2,
        //         time: 3000 //2秒关闭（如果不配置，默认是3秒）
        //     })
        //     return;
        // } else{
        //     userWeightCount = 0;
        // }
        // 平级
        var $lone2 = $("#taskBody1").find("tr.top2");
        for(var i=0;i<$lone2.length;i++){
            var qz2 = $("#taskBody1").find("tr.top2").eq(0).find("td").eq(1).find('input').val();
            var $trb2 = $($lone2).eq(i).find("td");
            var str2 = "";
            var assessmentRoleStr = "";
            if(qz2==""||qz2=="0"){
                if($($lone2).eq(i).find("td").eq(2).find("input").attr("user_id")!=undefined&&$($lone2).eq(i).find("td").eq(2).find("input").attr("user_id")!=''){
                    layer.msg("保存失败，未填写平级权重，请填写权重或者删除人员", {
                        icon: 2,
                        time: 3000 //2秒关闭（如果不配置，默认是3秒）
                    })
                    return;
                }
                str2 = "";
                $($lone2).eq(i).find("td").eq(2).find("input").attr("user_id","");
                $($lone2).eq(i).find("td").eq(2).find("input").attr("username","");
                $($lone2).eq(i).find("td").eq(2).find("input").attr("dataid","");
                $($lone2).eq(i).find("td").eq(2).find("input").attr("userprivname","");
                $($lone2).eq(i).find("td").eq(2).find("input").val("");
                $($lone2).eq(i).find("td").eq(4).text("");
            }else{
                var userId2 = $($lone2).eq(i).find("td").eq(2).find("input").attr("user_id");
                var userWeight2 = $($lone2).eq(i).find("td").eq(4).find('input').val();
                var assessmentRoleItem = $($lone2).eq(i).find("td").eq(3).find('input').val();
                if(i==0&&(userId2==undefined||userId2=='')){
                    layer.msg("保存失败，未选择平级人员，请选择人员或者删除权重", {
                        icon: 2,
                        time: 3000 //2秒关闭（如果不配置，默认是3秒）
                    })
                    return;
                }
                if(userId2!=undefined&&userId2!=''){
                    str2 = cha($($lone2).eq(i).find("td").eq(0).text())+"*"+cha1(userId2) + "|" + userWeight2;
                    assessmentRoleStr = cha($($lone2).eq(i).find("td").eq(0).text())+"*"+assessmentRoleItem
                    userWeightCount+=Number(keepTwoDecimalFull(userWeight2,4));
                    assessmentRoleArr.push(assessmentRoleStr);
                }
            }
            arr.push(str2);
            
        }
        // 判断平级人员总权重是否在0.99-1.01范围内
        if(userWeightCount > 0 && (keepTwoDecimalFull(userWeightCount) < 0.99 || keepTwoDecimalFull(userWeightCount) > 1.01)){
            layer.msg("保存失败，平级人员总权重不为1", {
                icon: 2,
                time: 3000 //2秒关闭（如果不配置，默认是3秒）
            })
            return;
        } else{
            userWeightCount = 0;
        }
        // if(Math.round(userWeightCount)>1||Math.round(userWeightCount)<0){
        //     layer.msg("保存失败，平级人员权重的和不在0-1范围内", {
        //         icon: 2,
        //         time: 3000 //2秒关闭（如果不配置，默认是3秒）
        //     })
        //     return;
        // } else{
        //     userWeightCount = 0;
        // }
        // 下级
        var $lone3 = $("#taskBody1").find("tr.top3");
        for(var i=0;i<$lone3.length;i++){
            var qz3 = $("#taskBody1").find("tr.top3").eq(0).find("td").eq(1).find('input').val();
            var $trb3 = $($lone3).eq(i).find("td");
            var str3 = "";
            var assessmentRoleStr = "";
            if(qz3==""||qz3=="0"){
                if($($lone3).eq(i).find("td").eq(2).find("input").attr("user_id")!=undefined&&$($lone3).eq(i).find("td").eq(2).find("input").attr("user_id")!=''){
                    layer.msg("保存失败，未填写下级权重，请填写权重或者删除人员", {
                        icon: 2,
                        time: 3000 //2秒关闭（如果不配置，默认是3秒）
                    })
                    return;
                }
                str3 = "";
                $($lone3).eq(i).find("td").eq(2).find("input").attr("user_id","");
                $($lone3).eq(i).find("td").eq(2).find("input").attr("username","");
                $($lone3).eq(i).find("td").eq(2).find("input").attr("dataid","");
                $($lone3).eq(i).find("td").eq(2).find("input").attr("userprivname","");
                $($lone3).eq(i).find("td").eq(2).find("input").val("");
                $($lone3).eq(i).find("td").eq(4).text("");
            }else{
                var userId3 = $($lone3).eq(i).find("td").eq(2).find("input").attr("user_id");
                var userWeight3 = $($lone3).eq(i).find("td").eq(4).find('input').val();
                var assessmentRoleItem = $($lone3).eq(i).find("td").eq(3).find('input').val();
                if(i==0&&(userId3==undefined||userId3=='')){
                    layer.msg("保存失败，未选择下级人员，请选择人员或者删除权重", {
                        icon: 2,
                        time: 3000 //2秒关闭（如果不配置，默认是3秒）
                    })
                    return;
                }
                if(userId3!=undefined&&userId3!=''){
                    str3 = cha($($lone3).eq(i).find("td").eq(0).text())+"*"+cha1(userId3) + "|" + userWeight3;
                    assessmentRoleStr = cha($($lone3).eq(i).find("td").eq(0).text())+"*"+assessmentRoleItem
                    userWeightCount+=Number(keepTwoDecimalFull(userWeight3, 4));
                    assessmentRoleArr.push(assessmentRoleStr);
                }
            }
            arr.push(str3);
            
        }
        // 判断下级人员总权重是否在0.99-1.01范围内
        if(userWeightCount > 0 && (keepTwoDecimalFull(userWeightCount) < 0.99 || keepTwoDecimalFull(userWeightCount) > 1.01)){
            layer.msg("保存失败，下级人员总权重不为1", {
                icon: 2,
                time: 3000 //2秒关闭（如果不配置，默认是3秒）
            })
            return;
        }
        // if(Math.round(userWeightCount)>1||Math.round(userWeightCount)<0){
        //     layer.msg("保存失败，下级人员权重的和不在0-1范围内", {
        //         icon: 2,
        //         time: 3000 //2秒关闭（如果不配置，默认是3秒）
        //     })
        //     return;
        // }

        function cha(data) {
            if(data == "上级"){
                return "1";
            }else if(data == "平级"){
                return "2";
            }else if(data == "下级"){
                return "3";
            }
        }
        function cha1(data) {
            if(data == undefined){
                return "";
            }else{
                return data.substring(0, data.length - 1)
            }
        }
        for(var z=0;z<arr.length;z++){
            if(arr[z]==""){
            }else{
                tyuu+= arr[z]+","
            }
        }
        /*考核角色*/
        for(var z=0;z<assessmentRoleArr.length;z++){
            if(assessmentRoleArr[z]==""){
                layer.msg("保存失败，有角色为空未设置", {
                    icon: 2,
                    time: 3000 //2秒关闭（如果不配置，默认是3秒）
                })
                return;
            }else{
                if(assessmentRoleArr[z].substr(2)==''){
                    layer.msg("保存失败，有角色为空未设置", {
                        icon: 2,
                        time: 3000 //2秒关闭（如果不配置，默认是3秒）
                    })
                    return;
                }
                assessmentRole+= assessmentRoleArr[z]+","
            }
        }

        $.ajax({
            url: '/scoreFlowUser/setAssessors',
            type: 'post',
            data: {
                scoreFlowId: flowId,
                privWeightStr:privWeightStr,
                assessorWeightStr: tyuu,
                userId:userId,
                insertType:getQueryString("insertType"),
                userIds:userIds,
                assessmentRole:assessmentRole
            },
            dataType: 'json',
            success: function (res) {
                if(res.code==0){
                    layer.msg("保存成功", {
                        icon: 1,
                        time: 1500 //2秒关闭（如果不配置，默认是3秒）
                    }, function () {
                        location.href = "/scoreFlowUser/userList?flowId="+flowId+'&flowFlag='+flowFlag
                    })
                }else{
                    layer.msg("保存失败", {
                        icon: 2,
                        time: 1500 //2秒关闭（如果不配置，默认是3秒）
                    })
                }


            }
        })
    })
    
    /**
     * 保留小数点后n位
     * @param num (数字)
     * @param n (小数点后几位，默认两位)
     */
    function keepTwoDecimalFull(num, n) {
        var result = parseFloat(num);
        if (isNaN(result)) {
            alert('传递参数错误，请检查！');
            return false;
        }
        if (isNaN(n) || !n || n <= 0) {
            n = 2;
        }
        var count = Math.pow(10, n);
        result = Math.round(num * count) / count;
        var s_x = result.toString();
        var pos_decimal = s_x.indexOf('.');
        if (pos_decimal < 0) {
            pos_decimal = s_x.length;
            s_x += '.';
        }
        while (s_x.length <= pos_decimal + n) {
            s_x += '0';
        }
        return s_x;
    }
    //返回
    $(document).on('click', '.back', function () {
        location.href="/scoreFlowUser/userList?flowId="+flowId+'&flowFlag='+flowFlag
    });
    function selectUserCb(res) {
        var tableN51=[];
        var $tableN=$("#taskBody1 .top").find('input[name="postPriv"]');
        for(var i=0;i<$tableN.length;i++){
            tableN51.push($($tableN).eq(i).attr("user_id"));
        }
        var $tableN2=$("#taskBody1 .top2").find('input[name="postPriv2"]');
        for(var i=0;i<$tableN2.length;i++){
            tableN51.push($($tableN2).eq(i).attr("user_id"));
        }
        var $tableN3=$("#taskBody1 .top3").find('input[name="postPriv3"]');
        for(var i=0;i<$tableN3.length;i++){
            tableN51.push($($tableN3).eq(i).attr("user_id"));
        }
        return tableN51;
    }

    function weightNum(e){

        var value = e.val();

        if(value>1){
            value='1';
        }

        if(value<0){
            value='0';
        }

        // 保留三位小数
        value = value.replace(/\D*(\d*)(\.?)(\d{0,4})\d*/,'$1$2$3');

        e.val(value);

    }

</script>
</body>
</html>

